package com.yaowen.edittext;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Main2Activity extends Activity {
    private EditText editText;
    private Button button, button2, button3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        editText = (EditText) findViewById(R.id.et1_2);
        //先找到表头linelayout
        //调用权限控制隐藏掉对应列
        //getView,

        button = (Button) findViewById(R.id.btn1_2);
        button2 = (Button) findViewById(R.id.noEditButton);
        button3 = (Button) findViewById(R.id.EditButton);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String str = editText.getText().toString();
                Toast.makeText(Main2Activity.this, str, Toast.LENGTH_LONG).show();
            }
        });
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                editText.setEnabled(false);
                editText.setTextColor(Color.rgb(0, 0, 0));//设置不可编辑状态时字体的颜色，不让其变灰；
                //editText.setBackgroundColor(Color.GREEN);
                //editText.setFocusable(false);
                //editText.setFocusableInTouchMode(false);
                Toast.makeText(Main2Activity.this, "editText不可编辑", Toast.LENGTH_SHORT).show();
            }
        });
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                editText.setEnabled(true);
                // editText.setFocusable(true);
                //editText.setFocusableInTouchMode(true);
                //editText.requestFocus();
                Toast.makeText(Main2Activity.this, "editText可以编辑", Toast.LENGTH_SHORT).show();
            }
        });
    }

}
